package com.example.test;

import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

public class Main01 {
    public static void main(String[] args) {

        String uri="D:/Projects/IdeaProjects/Idea2020/maven-test/netty-demo/nio-demo/src/main/resources/data/1.txt";
        try(FileInputStream fis=new FileInputStream(uri);
            FileChannel inputChannel = fis.getChannel()) {
            ByteBuffer buffer= ByteBuffer.allocate(10);
            int read = inputChannel.read(buffer);
            buffer.flip();
            int remaining = buffer.remaining();
            byte[] bytes=new byte[remaining];
            buffer.get(bytes);
            String s = new String(bytes);
//            String s = StandardCharsets.UTF_8.decode(buffer).toString();
            System.out.println();
        }catch (Exception e){

        }
    }
}
